package com.tiantian.quanminxiu.api;

import okhttp3.ResponseBody;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import rx.Observable;

//汇付宝服务器
public interface WeiXinService {

    class Factory {
        public static WeiXinService create() {
            Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl("https://api.weixin.qq.com/sns/")
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();
            return retrofit.create(WeiXinService.class);
        }
    }

    //region 微信获得授权 access_token
    @FormUrlEncoded
    @POST("oauth2/access_token")
    Observable<ResponseBody> access_token(@Field("appid") String appid, @Field("secret") String secret, @Field("code") String code,
                                     @Field("grant_type") String grant_type);
    //endregion
    //region 微信获取用户信息 response
    @FormUrlEncoded
    @POST("userinfo")
    Observable<ResponseBody> userinfo(@Field("access_token") String access_token, @Field("openid") String openid);
    //endregion
}
